<!DOCTYPE html>
<!--[if IE 8]> <html lang="zh-CN" class="ie8"> <![endif]-->
<html lang="zh-CN">

	<head>
		<meta charset="utf-8" />
		<title>结算页面</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta content="telephone=no,email=no,address=no" name="format-detection" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="msapplication-tap-highlight" content="no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="wap-font-scale" content="no">
		<meta name="Keywords" content="" />
		<meta name="Description" content="" />

		<link rel="stylesheet" href="__TMPL__Public/css/common.css" />
		<link rel="stylesheet" href="__TMPL__Public/css/public.css" />
		<link rel="stylesheet" href="/themes/wnsc_moblie/newMobile/Pay/Css/flow.css" />
		<link rel="stylesheet" href="/themes/wnsc_moblie/newMobile/Pay/Css/honeyswitch.css" />
		<script type="text/javascript" src="/themes/wnsc_moblie/newMobile/User/js/area/jquery.min.js"></script>
		<script type="text/javascript" src="__TMPL__Public/js/common.js"></script>
		<script type="text/javascript" src="/themes/wnsc_moblie/newMobile/Pay/js/honeyswitch.js"></script>

	</head>

	<body>
		<div class="content-main">
			<div class="content-info">
				<!-- 引入头部文件 -->
				<header>
					<div class="header" style="background: #f8f8f8;">
						<div class="header-left">
							<a class="sb-back" href="javascript:history.back(-1)" title="返回"></a>
						</div>
						<div class="header-middle">确认订单</div>
						<div class="header-right">
							<aside class="show-menu-btn">
								<div class="show-menu" id="show_more">
									<a href="javascript:void(0);"></a>
								</div>
							</aside>
						</div>
					</div>
				</header>
				<mtc_include file="Public:right_nav" />
				<!-- 收货地址 -->
				<div class="address-container border-line" id="addressinfo">
					<div id="user_address_list">
						<div class="main-content">
							<!--收货地址-->
							<notempty name="useraddress">
							<div class="address-info" onclick="window.location.href='{:U("user/address",Array("type"=>1))}'">
								<foreach name="useraddress" item="v">
									<php>$fapiao_hader=$v['consigner']</php>
									<dl>
										<dt>
										<p class="name-phone">
											<span class="name">收货人：{$v.consigner}</span>
											<span class="phone">{$v.mobile}</span>
										</p>
										<p class="address-address-detail">
											<span>收货地址：{$v.province}&nbsp;{$v.city}&nbsp;{$v.district} {$v.address}</span>
										</p>
										<i class="iconfont">&#xe607;</i>
									</dt>
									</dl>
								</foreach>
							</div>
							</notempty>
							<empty name="useraddress">
							<div class="address-none" onclick="window.location.href='{:U("user/address",Array("type"=>1,"noaddess"=>1))}'">
								<a href="javascript:void(0)" class="new-addr-add">
									<i class="iconfont"></i>
									新建收货地址
									<span class="right-arrow-flow ">
										<i class="iconfont"></i>
									</span>
								</a>
							</div>
							</empty>

						</div>

					</div>

				</div>
				<!-- 所有店铺商品清单 -->

				<div class="order-goods-box">
					<foreach name="result" item="vo">

						<!-- 商品清单 -->
						<div class="order-list">

							<foreach name="vo" item="v">
								<a href="{:U('shop/index',array('id'=>$v['shop_id']))}">
									<div class="order-list-goods goods_39815">
										<dl>
											<dt><img src="{$v.shop_picture}"></dt>
											<dd class="name"><strong>{$v.shop_name}</strong>
												<span>
													<notempty name="v['sku_spec']">
														规格：{$v.sku_spec}&nbsp;&nbsp;
													</notempty>
													<notempty name="v['sku_style']">
														颜色：{$v.sku_style}&nbsp;&nbsp;
													</notempty>
													<em class="goods-num">x{$v.num}</em>
              									</span>
												<span class="goods-price price-color">
              										<em>￥{:number_format($v['price'],2)}</em>
													<php>if($v['daiyan_sale']>0){</php>
              										<em style="font-size: 0.35rem;font-weight: normal;">抵扣券￥{:number_format($v['daiyan_sale'],2)}</em>
													<php>}</php>
              										<php>
														if($v['freight']==0){ $v['s_freight']='免运费'; }else{ $v['s_freight']=number_format($v['freight'],2); }
													</php>
													<em class="sku-line">运费：{$v['s_freight']}</em>
	              								</span>
											</dd>

										</dl>
									</div>
								</a>
								<php>
									$count['price']=$count['price']+($v['price']*$v['num']);
									 $count['num']=$count['num']+$v['num']; 
									 $count['c_freight']=$count['c_freight']+$v['freight'];
									 $count['daiyan_sale']=$count['daiyan_sale']+($v['daiyan_sale']*$v['num']); 
								</php>

							</foreach>
						</div>

					</foreach>

					<div class="goods-annex">
						<div class="goods-message">
							<span class="msg-title">支付方式：</span>
							<div class="invoice-name inv-info right-arrow-flow " id="invoice">
								<span>在线支付</span>
								<label for="invoice">&nbsp;</label>
								<i class="iconfont"></i>
							</div>
						</div>
					</div>

					<div class="goods-annex">
						<div class="goods-message">
							<span class="msg-title">优惠：</span>
							<div class="invoice-name inv-info right-arrow-flow " id="invoice">
								<select id="coupon" >
								<empty name="new_coupons"><option value="0" data_price="0">不使用</option></empty>
								<foreach name="new_coupons" item="v">
											<php>
												if($v['at_least']>$count['price']){
													$disabled='disabled';
												}else{
													$disabled='';
												}
											</php>
										<option value="{$v.coupon_type_id}" data_price="{$v.money}" {$disabled} >{$v.coupon_name}-{$v.xcy}</option>
									</foreach>
								</select>
							</div>
						</div>
					
					</div>

					<div class="goods-annex">
						<div class="goods-message">
							<span class="msg-title">发票信息：</span>
							<div class="invoice-name inv-info right-arrow-flow " id="invoice">
								<span class="switch-off" id="fapiao_button" style="margin: 12px;width: 50px;"></span>
							</div>
						</div>
						<div class="delivery-time order-blcok fapiao" id="set_time_blcok" style="display: none; padding:0 0.4rem;">
							<span class="msg-title">发票内容：</span>
							<div class="invoice-name inv-info right-arrow-flow " id="invoice">
								<span>选择</span>
								<label for="invoice">&nbsp;</label>
								<i class="iconfont"></i>
							</div>
						</div>
						<php>
							$web_qita=get_web_invoice(); $web_invoice=$web_qita['web_invoice']; $web_invoice_array=explode(',',$web_invoice);
						</php>
						<ul class="delivery-time-info" style="display: none;">
							<!-- 选中 给下面的div增加class值"active" 也就是class="box active" _star-->
							
							<foreach name="web_invoice_array" item="v" key="k">
							<li class="box <eq name='k' value='0'>active</eq>">
								<label>
									<input type="radio" data-set-time="{$v}" class="time-seleted best-time <eq name='k' value='0'>checked</eq>" name="best_time" >
									<span>{$v}</span>
								</label>
							</li>
							</foreach>
						</ul>
						<div class="goods-message fapiao" style="display: none;">
							<span class="msg-title">发票抬头：</span>
							<div class="buyer-msg" style="width: 70%;">
								<input type="text" name="fapiao_name" id="fapiao_name" value="{$fapiao_hader}" placeholder="请输入发票抬头，如：个人" />
							</div>
						</div>
					</div>

					<script type="text/javascript">
						$(function() {
							
							switchEvent("#fapiao_button", function() {
								$('.fapiao').show(500);
							}, function() {
								$('.fapiao').hide();
								$('.delivery-time-info').hide();
							});
							var fapiao=$('.delivery-time-info .active span').html();
							$('#set_time_blcok #invoice span').html(fapiao)
							console.log(fapiao)
							$('#set_time_blcok').click(function(){
								if($(this).hasClass('active')){
									$(this).removeClass('active');
									$('.delivery-time-info').hide();
								}else{
									$(this).addClass('active');
									$('.delivery-time-info').show(500);
								}
							})
							
							$('.delivery-time-info li').click(function(){
								fapiao=$(this).find('span').html();
								$('.delivery-time-info li').removeClass('active');
								$(this).addClass('active');
								//$('.delivery-time-info li').find('input:radio').removeAttr("checked");
								$('.delivery-time-info li').find('input:radio').removeClass("checked");
								//$('.delivery-time-info .active').find('input:radio').attr("checked",'true');
								$('.delivery-time-info .active').find('input:radio').addClass("checked");
								$('#set_time_blcok #invoice span').html(fapiao)
							})
							
							var obj=document.getElementById("coupon");  
							var index=obj.selectedIndex;  
							var prcie=obj.options[index].getAttribute("data_price");  
							$('.youhui').html('-￥'+prcie);
							var count_price=$('#count_price_gg').val();
							var count_price=parseInt(count_price);
							var prcie=parseInt(prcie);
							var cha_price=count_price-prcie;
							$('.SZY-ORDER-MONEY-PAY').html(cha_price.toFixed(2));
							
							$("#coupon").change(function(){
								var obj=document.getElementById("coupon");  
								var index=obj.selectedIndex;  
								var prcie=obj.options[index].getAttribute("data_price");  
								$('.youhui').html('-￥'+prcie);
								var count_price=$('#count_price_gg').val();
								var count_price=parseInt(count_price);
								var prcie=parseInt(prcie);
								var cha_price=count_price-prcie;
								$('.SZY-ORDER-MONEY-PAY').html(cha_price.toFixed(2));
							
								
							});
						})
					</script>
		<input type="hidden"  id="count_price_gg" value="{$count['price']+$count['c_freight']}" />
					<div class="goods-annex">
						<div class="goods-message">
							<span class="msg-title">买家留言：</span>
							<div class="buyer-msg"><textarea class="text postscript" placeholder="选填，可填写您与卖家达成一致的要求"></textarea></div>
						</div>
					</div>
					<div class="checkbar" id="shop_count_3">
						<div class="real-pay">
							<span class="hd">合计：</span>
							<span class="bd">
								<em class="SZY-SHOP-ORDER-AMOUNT-3 price-color" data-shop-id="3">￥{:number_format($count['price'],2)}</em>
							</span>
						</div>
					</div>
				</div>
				<!-- 支付方式 -->
				<div class="pay-type-content">
					<!-- 余额支付 -->

					<div class="total-count-pay-con">
						<div class="total-count-pay-info">
							<span class="info-l">商品总额</span>
							<span class="info-r SZY-GOODS-AMOUNT price-color">￥{:number_format($count['price'],2)}</span>
						</div>
						<div class="total-count-pay-info">
							<span class="info-l">运费</span>
							<span class="info-r SZY-SHIPPING-FEE-AMOUNT price-color">+￥{:number_format($count['c_freight'],2)}</span>
						</div>

						<div class="total-count-pay-info">
							<span class="info-l">优惠券</span>
							<span class="info-r price-color youhui">-￥0</span>
						</div>
						<div class="total-count-pay-info">
							<span class="info-l">抵扣券</span>
							<span class="info-r price-color ">-￥{$count['daiyan_sale']}</span>
						</div>
					</div>

					
					
				</div>

				<!-- 提交订单 -->
				<div class="confirm-pay" id="checkout_amount">
					<div style="height: 2rem; line-height: 2rem"></div>
					<div class="order-footer">
						<div class="total">
							<dl class="total-money">
								<dt>合计：</dt>
								<php>
									$yf_price=$count['price']+$count['c_freight']-$count['daiyan_sale'];
									if($yf_price<0){
										$yf_price=0;
									}
								</php>
								<dd class="SZY-ORDER-MONEY-PAY price-color"><em>￥{:number_format($yf_price,2)}</em></dd>
							</dl>
						</div>
						<div class="order-btn bg-color">
							<a href="javascript:void(0)" class="gopay">提交订单</a>
						</div>
					</div>
				</div>

			</div>
		</div>
		<script src="/themes/wnsc_moblie/newMobile/Shop/js/mobile/layer.js"></script>
		<script type="text/javascript">
			$(function(){
				$('.gopay').click(function(){
					var is_invoice=$('#invoice span').hasClass('switch-off');
					if(is_invoice){
						//关闭
						var invoice_title='';
						var invoice_content='';
						var invoice_status=0;
					}else{
						//开启
						var invoice_title=$('#fapiao_name').val();
						var invoice_content=$('#set_time_blcok #invoice span').html();;
						var invoice_status=1;
						if(invoice_title==''){
							 layer.open({
							    content: '请填写发票抬头'
							    ,skin: 'msg'
							    ,time: 2 //2秒后自动关闭
							  });
							
							return false;
						}
						if(invoice_content==undefined){
							layer.open({
							    content: '请填写发票内容'
							    ,skin: 'msg'
							    ,time: 2 //2秒后自动关闭
							});
							return false;
						}
					}
					var leavemessage=$('.postscript').val();
					var coupon=$('#coupon').val();

					$.ajax({
						url : "/pay/generate_order",
						type : "post",
						data : { 
							"leavemessage" : leavemessage,
							"invoice_title" : invoice_title,
							"invoice_content" : invoice_content,
							"invoice_status" : invoice_status,
							"coupon" : coupon,
						},
						success : function(res){
							if(res.code==1){
								window.location.href="/pay/paychoose/order_cn/"+res.data;
							}else{
								layer.open({
								    content: res.message
								    ,skin: 'msg'
								    ,time: 2 //2秒后自动关闭
								});
								
							}
						}
					});
					
				})
			})
		</script>
	</body>
	<!--<mtc_include file="Public:footer" />
-->

</html>